<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('标签列表')" />
	<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>

							<li>
								标签ID：<input type="text" name="tagId"/>
							</li>
							<li>
								标签类型：<input type="text" name="tagType"/>
							</li>

<!--							<li>-->
<!--								电量：<input type="text" name="batteryVoltage"/>-->
<!--							</li>-->

							<li>
								是否低电：<select name="isLow" th:with="type=${@dict.getType('sys_is_low')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								在线情况：<select name="isOnline" th:with="type=${@dict.getType('sys_is_online')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								绑定状态：<select name="isBind" th:with="type=${@dict.getType('sys_bind_status')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
<!--							<li>-->
<!--								创建时间：-->
<!--									<input type="text" class="input-sm form-control1" id="startTime" placeholder="开始时间" name="params[beginTime]" />-->
<!--							<li>-->
<!--								<input type="text" class="input-sm form-control" id="endTime" placeholder="结束时间"  name="params[endTime]" style="width: 150px"/>-->

<!--							<li class="select-time new">-->
<!--								<label class="font-noraml">创建时间：</label>-->
<!--								<div class="input-daterange input-group">-->
<!--									<input type="text" class="input-sm form-control" id="startTime" placeholder="开始时间" name="params[beginTime]"/>-->
<!--									<span>-</span>-->
<!--									<input type="text" class="input-sm form-control" id="endTime" placeholder="结束时间"  name="params[endTime]"/>-->
<!--								</div>-->
<!--							</li>-->
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addDeviceModel()" shiro:hasPermission="system:lable:add">
					<i class="fa fa-plus"></i> 添加
				</a>
<!--				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.editDeviceModel()" shiro:hasPermission="system:lable:edit">-->
<!--					<i class="fa fa-edit"></i> 修改-->
<!--				</a>-->
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeIsBindAll()" shiro:hasPermission="system:lable:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:lable:export">
						<i class="fa fa-download"></i> 导出
				 </a>

<!--				<a class="btn btn-success" onclick="$.operate.rpcToDevice()" shiro:hasPermission="system:lable:rpcToDevice">-->
<!--					<i class="fa fa-plus"></i> 下发-->
<!--				</a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	 <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:lable:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:lable:remove')}]];
        var prefix = ctx + "system/lable";
		var types = [[${@dict.getType('sys_is_online')}]];
		var tagId = [[${tagId}]];
        $(function() {
			$('input:not([autocomplete]),textarea:not([autocomplete]),select:not([autocomplete])').attr('autocomplete', 'off');
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				rpcToDeviceUrl: prefix + "/rpcToDevice",
				exportUrl: prefix + "/export",
                modalName: "标签",
		        showExport: false,
				queryParams:queryParams,
				uniqueId:"tagId",
                columns: [{
		            checkbox: true
		        },
				{
					title: "序号",
					formatter: function (value, row, index) {
						return $.table.serialNumber(index);
					}
				},
				{
					field : 'tagId',
					title : '标签ID',
					sortable: true,
					visible: true,
					formatter: function(value, row, index) {
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'personId',
					title : '人员ID',
					sortable: true,
					visible: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'modelType',
					title : '标签类型',
					sortable: true,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'modelNumber',
					title : '标签型号',
					sortable: true,
					formatter: function(value, row, index) {
						var tooltip = $.table.tooltip(value);
						tooltip = $.common.nullToStr(tooltip);
						var html ="<span style='white-space:nowrap'>"+tooltip+"</span>";
						return html;
					}
				},
					{
						field : 'isOnline',
						title : '在线情况',
						sortable: true,
						visible: true,
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(types, value);
						}
					},
					{
						field : 'positionTS',
						title : '位置信息时间',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'lastPacketTS',
						title : '数据产生时间',
						sortable: true,
						visible: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'x,y,z',
						title : '位置坐标',
						sortable: false,
						visible: true,
						formatter:function (value,row,index) {
							var x = $.common.nullTonbsp(row.x);
							var y = $.common.nullTonbsp(row.y);
							var z = $.common.nullTonbsp(row.z);
							var html ="<span style='white-space:nowrap'></span><span>"+x+",</span><span>"+y+",</span><span>"+z+"</span></span>"
							return html;
						}
					},
					// {
					// 	field : 'y',
					// 	title : 'Y',
					// 	sortable: true,
					// 	visible: false
					// },
					// {
					// 	field : 'z',
					// 	title : 'Z',
					// 	sortable: true,
					// 	visible: false
					// },
					{
						field : 'batteryVoltage',
						title : '电池电量',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'batteryVoltageTS',
						title : '电池电量时间',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'rssi',
						title : '信号强度',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'rssiLocator',
						title : 'rssi基站ID',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'status',
						title : '报警状态',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'sensorType',
						title : '传感类型',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					{
						field : 'sensorData',
						title : '传感值',
						sortable: false,
						formatter: function(value, row, index) {
							value = $.common.nullToStr(value);
							var html ="<span style='white-space:nowrap'>"+value+"</span>"
							return html;
						}
					},
					// {
					// 	field : 'personId',
					// 	title : '人员ID',
					// 	sortable: true,
					// 	visible: false
					// },
				{
					field : 'createBy', 
					title : '创建者',
					sortable: true,
					visible: false,
					formatter: function(value, row, index) {
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true,
					visible: false,
					formatter: function(value, row, index) {
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'updateBy', 
					title : '更新者',
					sortable: false,
					visible: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: false,
					visible: true,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var html ="<span style='white-space:nowrap'>"+value+"</span>"
						return html;
					}
				},
				{
					field : 'remark', 
					title : '备注',
					sortable: false,
					visible: false,
					formatter: function(value, row, index) {
						value = $.common.nullToStr(value);
						var tooltip = $.table.tooltip(value);
						var html ="<span style='white-space:nowrap'>"+tooltip+"</span>"
						return html;
					}
				},
		        {
		            title: '操作',
		            align: 'center',
					width: "500px",
		            formatter: function(value, row, index) {
		            	var actions = [];
						actions.push('<span style=\'white-space:nowrap\'>');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.editDeviceModel(\'' + row.tagId + '\')"><i class="fa fa-edit"></i>备注</a> ');
						actions.push('<a class="btn btn-info btn-xs" href="#" onclick="showPerson(\'' + row.personId + '\')"><i class="fa fa-search"></i> 查看</a> ');
						actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="#" onclick="locationAlarm(\'' + row.tagId + '\')"><i class="fa fa-play-circle-o"></i>定位</a> ');
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.removeIsBind(\'' + row.tagId + '\')"><i class="fa fa-remove"></i>删除</a>');
						actions.push('</span>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
			$("#startTime").datetimepicker({
				format: "yyyy-mm-dd hh:ii:ss",
				autoclose: true
			});
			$("#endTime").datetimepicker({
				format: "yyyy-mm-dd hh:ii:ss",
				autoclose: true
			});
        });
		// 修改信息
		function showPerson(personId) {
			if (personId==null||personId==""||personId=="null"){
				$.modal.alert("未绑定人员信息");
				return;
			} else {
				$.modal.openDetails("查看人员信息", "/system/person/details/"+personId,"980","800");
			}
		}
		function locationAlarm(id) {
			$.modal.openTab("定位" + $.table._option.modalName,"/mapIndex/"+id);
		}
		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.tagId = tagId;
			return search;
		}
    </script>
</body>
</html>